var page = 1;
document.querySelector("#btn").addEventListener('click',function () {
    if (page < 2 ){
        page++;
        document.querySelector("#list").innerHTML = "";
    }else {
        page++;
        alert("这是最后一个")
    }


    loadXMLDoc();
});

function loadXMLDoc() {
    var xmlhttp;
    if (window.XMLHttpRequest) {
        //  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
        xmlhttp=new XMLHttpRequest();
    }
    else {
        // IE6, IE5 浏览器执行代码
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4 && xmlhttp.status==200) {
        var json = xmlhttp.responseText;
            json = JSON.parse(json);
            console.log(json)
          for (var i = 0;i<json.shop.length;i++){
              console.log(json.shop[i]);
              //创造节点
              var img = document.createElement('img');
              img.src = json.shop[i].pic;
              var h3 = document.createElement('h3');
              h3.innerHTML = json.shop[i].title;
              var p = document.createElement('p');
              p.innerHTML = json.shop[i].price;

              var div = document.createElement('div');

              div.appendChild(img);
              div.appendChild(h3);
              div.appendChild(p);

              document.querySelector("#list").appendChild(div);
          }

        }
    };
    xmlhttp.open("GET",page +"tsconfig.json",true);
    xmlhttp.send();
}
loadXMLDoc();